//
//  TestCell.m
//  TableView 封装
//
//  Created by Kevin on 17/11/1.
//  Copyright © 2017年 JOWO.team. All rights reserved.
//

#import "TestCell.h"
#import "UIButton+Bolck.h"
@interface TestCell ()
@property (nonatomic, copy) deleteCellBlock block;

@property (nonatomic, assign) NSInteger cellIndex;
@end

@implementation TestCell


+ (id)creatXibCellWithTarget:(id)target index:(NSIndexPath *)index tableView:(UITableView *)tableView model:(TestModel *)model{
    static NSString *identifer = @"TestCell";
    TestCell *cell = [tableView dequeueReusableCellWithIdentifier:identifer];
    
    if (!cell) {
        cell = (TestCell *)[[[NSBundle mainBundle] loadNibNamed:@"TestCell" owner:self options:nil] lastObject];
    }
    
    cell.deleteBtn.tag = index.row;
    
    [cell.deleteBtn HandleClickEvent:UIControlEventTouchUpInside withClickBlick:^{
//        cell.cellIndex = cell.deleteBtn.tag;
        if (cell.block) {
            cell.block(cell.deleteBtn.tag);
        }
    }];
    cell.title.text = model.title;
    return cell;
}
//- (IBAction)deleBtnActioning:(UIButton *)sender {
//    self.cellIndex = [NSIndexPath indexPathForRow:sender.tag inSection:0];
//    if (self.block) {
//        self.block(self.cellIndex);
//    }
//}

- (void)deleteCellWithIndex:(deleteCellBlock)deleteBlock{
    self.block = deleteBlock;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
